<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
	String finance_dept_id = request.getParameter("finance_dept_id") == null ? "" : request.getParameter("finance_dept_id");
%>
<html>
	<head>
		<title>部门账户日志</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$('#table').datagrid({
				title:'账户往来明细',
				rownumber:true,
				url:'<%=contextPath %>/springMVC/finance/listPageFinanceDeptLog?finance_dept_id=<%=finance_dept_id%>', 
				loadMsg:'正在加载数据，请稍后......',
				fitColumns:true,
				nowrap:false,
				columns:[[
					{title:'id',field:'id',hidden:true},
					{title:'凭证类型',field:'proof_type',hidden:true},
					{title:'凭证id',field:'proof_id',hidden:true},
					{title:'时间',field:'operation_date',width:200,align:'center'},
					{title:'摘要',field:'summary',width:300,align:'center'},
					{title:'类别',field:'type',width:50,align:'center',formatter:function(value,row,index){
						if(value == "1")
						{
							return "<img src='<%=contextPath %>/public/easyui1.4/themes/icons/receive.gif'  title='收入'/>";
						}
						if(value == "2")
						{
							return "<img src='<%=contextPath %>/public/easyui1.4/themes/icons/zc.gif'  title='支出'/>";
						}
						return "";
					}},
					{title:'交易前金额',field:'before_money',width:200,align:'center',formatter:function(value,row,index){
						if(row.type == '0'){
							return "";
						}else{
							return value;
						}
					}},
					{title:'本次发生额',field:'money',width:200,align:'center'},
					{title:'交易后余额',field:'afterMoney',width:200,align:'center',formatter:function(value,row,index){
						if(row.type == '0'){
							return row.money;
						}
						if(row.type == '1'){
							return Math.round((parseFloat(row.before_money)+parseFloat(row.money))*Math.pow(10,2))/Math.pow(10,2);
						}
						if(row.type == '2'){
							return Math.round((parseFloat(row.before_money)-parseFloat(row.money))*Math.pow(10,2))/Math.pow(10,2);
						}
					}},
					{title:'查看凭证',field:'detail',width:50,align:'center',formatter:function(value,rowData,rowIndex){
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_Self_Request%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showSelfRequest('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_Self_DB_Out%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showSelfDB('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_LOAN_Out%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewLoan('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_Advances_Out%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewAdvances('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_Yet_Advances_IN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewYetAdvances('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_REM%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showReim(1,'"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_REM_LOAN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showReim(2,'"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_XM_EVAL%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showEval('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_XM_EARN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showEarn('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_XM_SUPPLY_PAY%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewXmPay(2,'"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_XM_WORKER_PAY%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewXmPay(1,'"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_COMMONS%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewCommons('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_OUTLOAN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewLoanOut('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_INLOAN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewLoanIn('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_EMPLOYEE_LOAN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewEmployeeLoanIn('"+rowData.proof_id+"')\"/>";
						}
						if(rowData.proof_type == '<%=com.beaut.project.util.StaticData.Proof_EMPLOYEE_YET_LOAN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"viewEmployeeYetLoanIn('"+rowData.proof_id+"')\"/>";
						}
					}}
				]],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						warningInfo(rtJson.rtMsrg);
					}
				}
			});
			//----end
		});
		function  viewXmPay(type,id){
			 if(type==1){
			 	openDialogResize("<%=contextPath %>/springViews/finance/showWorkPay.jsp?id="+id+"&callback=rtCallBack&isShow=1",1000, 800);
			 }else{
				openDialogResize("<%=contextPath %>/springViews/finance/showSupplierPay.jsp?id="+id+"&callback=rtCallBack&isShow=1",1000, 800);
			}
		
			}
		function showSelfRequest(request_id){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditSelfRequest.jsp?isShow=1&id='+request_id,1000, 800);	
		}
		function showSelfDB(db_log_id){
			openDialogResize('<%=contextPath %>/springViews/warehouse/dbMyDetailsForLog.jsp?db_log_id='+db_log_id,1000, 800);	
		}
		function viewLoan(id){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditLoan.jsp?id='+id+"&isShow=1",1000, 800);	
		}
		function viewAdvances(id){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditAdvances.jsp?id='+id+"&isShow=1",1000, 800);	
		}
		function viewYetAdvances(id){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditYetAdvances.jsp?id='+id+"&isShow=1",1000, 800);	
		}
		function showEval(id){
        	openDialogResize("<%=contextPath %>/springViews/xm/addOrEditFinanceEValuation.jsp?id="+id+"&callback=rtCallBack&isShow=1",1000, 800);
        }
		function showReim(type,id){
			if(type==1){
				openDialogResize("<%=contextPath %>/springViews/xm/addOrEditReimbursement.jsp?isShow=1&callback=rtCallBack&id="+id,1000, 800);
			}else{
				openDialogResize("<%=contextPath %>/springViews/xm/addOrEditReimbursementByLoan.jsp?isShow=1&callback=rtCallBack&id="+id,1000, 800);
			}
		}
		 function showEarn(id){
				openDialogResize("<%=contextPath %>/springViews/xm/addOrEditInMoney.jsp?isShow=1&callback=rtCallBack&id="+id,1000, 800);
		 }
	 	function viewCommons(id){
			openDialogResize("<%=contextPath %>/springViews/finance/addOrEditFinanceCommons.jsp?isShow=1&id="+id,1000, 800);
		 }
	  	function viewLoanOut(id){
			openDialogResize("<%=contextPath %>/springViews/finance/addOrEditFinanceLoan.jsp?isShow=1&id="+id,1000, 800);
		 }
	  	function viewLoanIn(id){
			openDialogResize("<%=contextPath %>/springViews/finance/addOrEditFinanceYetLoan.jsp?isShow=1&yet_id="+id,1000, 800);
		 }
	  	function viewEmployeeLoanIn(id){
			openDialogResize("<%=contextPath %>/springViews/finance/addOrEditEmployeeLoan.jsp?isShow=1&id="+id,1000, 800);
		 }
	 	function viewEmployeeYetLoanIn(id){
			openDialogResize("<%=contextPath %>/springViews/finance/addOrEditReimbursemeEmployeeLoan.jsp?isShow=1&id="+id,1000, 800);
		}
		function doSearch(){
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			$('#table').datagrid('load',{
				start_date:start_date,
				end_date:end_date,
				finance_dept_id:'<%=finance_dept_id%>'
			});
		}

		//弹出警告框信息
		function warningInfo(msg){
			jQuery.messager.alert('提示：',msg);
		}
		function ExcelOut(){
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			window.open('<%=contextPath %>/springMVC/excel/listFinanceDeptLogExcel?finance_dept_id=<%=finance_dept_id%>'+"&start_date="+start_date+"&end_date="+end_date);
		}
	</script>
	<body>
		    	    <div id="table"  data-options="fit:true,toolbar:'#queryParamDiv'"></div>  
		    	    <div id="queryParamDiv" style="padding:3px;height:auto">
						<div align="right">
							开始日期: <input id="start_date" name="start_date" class="easyui-datebox" style="width:100px;"/>
							结束日期: <input id="end_date" name="end_date" class="easyui-datebox" style="width:100px;"/>&nbsp;&nbsp;
							<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();">搜索</a>
							<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-excel' title='导出Excel' onclick='ExcelOut()'/>
						
						</div>
					</div>
	</body>
</html>
